package com.example.parion;

import android.accessibilityservice.AccessibilityService;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
import android.view.accessibility.AccessibilityEvent;

public class MyAccessibilityService extends AccessibilityService {
	
	public static final String Receivekakao = "receive_kakao";

	@Override
	public void onAccessibilityEvent(AccessibilityEvent event) {
//		 TODO Auto-generated method stub
		Log.d("AccessibilityService","AccessibilityService");
		if(event.getEventType()==AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED)
		{
			if(event.getPackageName().equals("com.kakao.talk"))
			{
				if(event.getText().toString().equals("[]"))
					return;				
				Log.d("dddddddddddddddddddddd",event.getText().toString());
				Intent intent = new Intent(MyApplication.getContext(), SaveDataService.class);
                intent.putExtra("TAG", Receivekakao);
                intent.putExtra("content", event.getText().toString());
                MyApplication.getContext().startService(intent);
                return;
			}
			
		}
	}

	@Override
	protected void onServiceConnected() {
		// TODO Auto-generated method stub
		super.onServiceConnected();
		
		
		Log.d("onServiceConnected","onServiceConnected");
		
		AccessibilityServiceInfo aaa = new AccessibilityServiceInfo();
		aaa.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED;
		aaa.notificationTimeout=80L;
		aaa.feedbackType = AccessibilityServiceInfo.DEFAULT;
		setServiceInfo(aaa);
		
		
	}

	@Override
	public void onInterrupt() {
		// TODO Auto-generated method stub
		
	}

}

